import java.util.Scanner;

public class Selflearn_12 {
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int oa=a,ob=b;
        while(b!=0){
            int temp=a%b;
            a=b;
            b=temp;
        }
        System.out.println(oa+"和"+ob+"的最大公约数为"+a);
    }
}
//用辗转相除法算最大公约数